package com.cib.process.chat.core.handler.impl;

import com.cib.process.bean.CheckType;
import com.cib.process.bean.ServiceResult;
import com.cib.process.chat.bean.Completekey;
import com.cib.process.chat.bean.PasswordActionResult;
import com.cib.process.chat.bean.PlayType;
import com.cib.process.chat.bean.QueryResult;
import com.cib.process.chat.core.handler.ActionHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.validation.constraints.Max;

@Service
public class PasswordActionHandler implements ActionHandler {
    @Value("${action.1002.result.minkey:6}")
    private String minkey;
    @Value("${action.1002.result.maxkey:6}")
    private String maxkey;
    @Value("${action.1002.result.canbreak:N}")
    private String canbreak;
    @Value("${action.1002.result.recordflag:N}")
    private CheckType recordflag;
    @Value("${action.1002.result.poundflag:Y}")
    private CheckType poundflag;
    
    @Override
    public ServiceResult execute(QueryResult queryResult) {
        PasswordActionResult result=new PasswordActionResult();
        result.setMinkey(minkey);
        result.setMaxkey(maxkey);
        result.setCompleteKey(Completekey.NUM.getCode());
        result.setPassword_type(queryResult.getPwdType());
        result.setCheck_password(queryResult.getCheckPwd());
        result.setType(PlayType.TTS);
        //密码类型待定，确认是否需要

        result.setContext(queryResult.getSuggestAnswer());
        result.setCanbreak(canbreak);
        result.setPoundflag(poundflag);
        result.setRecordflag(recordflag);
        result.setKh("1".equals(queryResult.getPwdType())?queryResult.getCreditId():"");
        return ServiceResult.buildSuccessResult(result,queryResult.getSessionId(),queryResult.getAction());

    }
}
